package com.hsu.example.consumer;

import com.hsu.example.common.model.User;
import com.hsu.example.common.service.UserService;
import com.hsu.hsurpc.proxy.ServiceProxyFactory;

/**
 * 简易服务消费者示例
 * @Author Hsu琛君珩
 * @Date 2024-09-18 14:09
 * @Description
 * @Version: v1.0.0
 */
public class ConsumerExample {

    public static void main(String[] args) throws InterruptedException {
        // 获取代理
        UserService userService = ServiceProxyFactory.getProxy(UserService.class);
        // 打印服务名称和版本，确认与提供者一致
        System.out.println("查找服务：" + UserService.class.getName());
        User user = new User();
        user.setName("hsurosy");
        // 调用
        User newUser = userService.getUser(user);
        if (newUser != null) {
            System.out.println("getUser 返回: " + newUser.getName());
            System.out.println(newUser.getName());
        } else {
            System.out.println("getUser 返回: user == null");
            System.out.println("user == null");
        }
    }
}
